﻿using System;
using BP.En;
using BP.WF;


namespace BP.CCBill.WorkOpt
{
    /// <summary>
    /// 预置审核人 - Attr
    /// </summary>
    public class WorkSettingAttr
    {
        #region 基本属性1
        /// <summary>
        /// 工作ID
        /// </summary>
        public const string WorkID = "WorkID";
        /// <summary>
        /// 表单ID
        /// </summary>
        public const string FrmID = "FrmID";
        /// <summary>
        /// 关联的单据号
        /// </summary>
        public const string FrmName = "FrmName";
        #endregion

        #region 基本属性
        /// <summary>
        /// 单据状态
        /// </summary>
        public const string BillState = "BillState";
        /// <summary>
        /// 标题
        /// </summary>
        public const string Title = "Title";
        /// <summary>
        /// 发起人
        /// </summary>
        public const string Starter = "Starter";
        /// <summary>
        /// 发起人名称
        /// </summary>
        public const string StarterName = "StarterName";
        /// <summary>
        /// 当前步骤.
        /// </summary>
        public const string Idx = "Idx";
        /// <summary>
        /// 单据编号
        /// </summary>
        public const string BillNo = "BillNo";
        /// <summary>
        /// 参与人
        /// </summary>
        public const string Emps = "Emps";
        #endregion
    }
    /// <summary>
    /// 预置审核人
    /// </summary>
    public class WorkSetting : Entity
    {
        #region 属性
        /// <summary>
        /// 主键
        /// </summary>
        public override string PK
        {
            get
            {
                return WorkSettingAttr.WorkID;
            }
        }

        /// <summary>
        /// BillNo
        /// </summary>
        public string BillNo
        {
            get
            {
                return this.GetValStrByKey(WorkSettingAttr.BillNo);
            }
            set
            {
                SetValByKey(WorkSettingAttr.BillNo, value);
            }
        }
        /// <summary>
        /// 单据ID
        /// </summary>
        public string FrmID
        {
            get
            {
                return this.GetValStrByKey(WorkSettingAttr.FrmID);
            }
            set
            {
                SetValByKey(WorkSettingAttr.FrmID, value);
            }
        }
        /// <summary>
        /// 单据单据
        /// </summary>
        public string FrmName
        {
            get
            {
                return this.GetValStrByKey(WorkSettingAttr.FrmName);
            }
            set
            {
                SetValByKey(WorkSettingAttr.FrmName, value);
            }
        }
        /// <summary>
        /// 参与人
        /// </summary>
        public string Emps
        {
            get
            {
                return this.GetValStrByKey(WorkSettingAttr.Emps);
            }
            set
            {
                SetValByKey(WorkSettingAttr.Emps, value);
            }
        }
        /// <summary>
        /// 标题
        /// </summary>
        public string Title
        {
            get
            {
                return this.GetValStrByKey(WorkSettingAttr.Title);
            }
            set
            {
                SetValByKey(WorkSettingAttr.Title, value);
            }
        }
        /// <summary>
        /// 单据ID
        /// </summary>
        public Int64 WorkID
        {
            get
            {
                return this.GetValInt64ByKey(WorkSettingAttr.WorkID);
            }
            set
            {
                SetValByKey(WorkSettingAttr.WorkID, value);
            }
        }
        /// <summary>
        /// 发起人
        /// </summary>
        public string Starter
        {
            get
            {
                return this.GetValStrByKey(WorkSettingAttr.Starter);
            }
            set
            {
                SetValByKey(WorkSettingAttr.Starter, value);
            }
        }
        /// <summary>
        /// 发起人名称
        /// </summary>
        public string StarterName
        {
            get
            {
                return this.GetValStrByKey(WorkSettingAttr.StarterName);
            }
            set
            {
                this.SetValByKey(WorkSettingAttr.StarterName, value);
            }
        }
         
        /// <summary>
        /// 工作单据状态
        /// </summary>
        public BillState BillState
        {
            get
            {
                return (BillState)this.GetValIntByKey(WorkSettingAttr.BillState);
            }
            set
            {
                //if (value == BillState.)
                //    SetValByKey(WorkSettingAttr.BillSta, (int)BillSta.Complete);
                //else if (value == BP.WF.BillState.Delete)
                //    SetValByKey(WorkSettingAttr.BillSta, (int)BillSta.Etc);
                //else
                //    SetValByKey(WorkSettingAttr.BillSta, (int)BillSta.Runing);
                SetValByKey(WorkSettingAttr.BillState, (int)value);
            }
        }
        /// <summary>
        /// 单据状态
        /// </summary>
        public string BillStateText
        {
            get
            {
                return this.GetValRefTextByKey(WorkSettingAttr.BillState);
            }
        }
        #endregion

        #region 权限控制.
        public override UAC HisUAC
        {
            get
            {
                UAC uac = new UAC();
                if (BP.Web.WebUser.No.Equals("admin")==true)
                {
                    uac.IsDelete = false;
                    uac.IsUpdate = true;
                    return uac;
                }
                uac.Readonly();
                return uac;
            }
        }
        #endregion 权限控制.

        #region 构造方法
        /// <summary>
        /// 预置审核人
        /// </summary>
        public WorkSetting()
        {
        }
        /// <summary>
        /// 预置审核人
        /// </summary>
        /// <param name="workID">workID</param>
        public WorkSetting(Int64 workid)
        {
            this.WorkID = workid;
            this.Retrieve();
        }
        /// <summary>
        /// EnMap
        /// </summary>
        public override Map EnMap
        {
            get
            {
                if (this._enMap != null)
                    return this._enMap;
                Map map = new Map("Frm_WorkSetting", "预置审核人");

                map.AddTBIntPK(WorkSettingAttr.WorkID, 0, "WorkID", true, true);

                map.AddTBString(WorkSettingAttr.FrmID, null, "单据ID", true, false, 0, 100, 10);
                map.AddTBString(WorkSettingAttr.FrmName, null, "单据名称", true, false, 0, 200, 10);

                map.AddTBString(WorkSettingAttr.BillNo, null, "单据编号", true, false, 0, 100, 10);
                map.AddTBString(WorkSettingAttr.Title, null, "标题", true, false, 0, 1000, 10);
                //map.AddDDLSysEnum(WorkSettingAttr.BillSta, 0, "状态(简)", true, false, WorkSettingAttr.BillSta, "@0=运行中@1=已完成@2=其他");
                map.AddDDLSysEnum(WorkSettingAttr.BillState, 0, "单据状态", true, false, WorkSettingAttr.BillState, "@0=空白@1=草稿@2=编辑中@3=申请提交@4=审核中@100=归档");

                map.AddTBString(WorkSettingAttr.Starter, null, "创建人", true, false, 0, 200, 10);
                map.AddTBString(WorkSettingAttr.StarterName, null, "创建人名称", true, false, 0, 200, 10);

                map.AddTBString(WorkSettingAttr.Emps, null, "参与人", true, false, 0, 4000, 10);

                //设置参数.
                map.AddTBAtParas(3000);
                this._enMap = map;
                return this._enMap;
            }
        }
        #endregion

        #region 方法操作.
        #endregion 方法操作.
    }
    /// <summary>
    /// 预置审核人s
    /// </summary>
    public class WorkSettings : Entities
    {
        #region 构造
        /// <summary>
        /// 预置审核人s
        /// </summary>
        public WorkSettings()
        {
        }
        /// <summary>
        /// 得到它的 Entity
        /// </summary>
        public override Entity GetNewEntity
        {
            get
            {
                return new WorkSetting();
            }
        }
        #endregion

        #region 为了适应自动翻译成java的需要,把实体转换成List.
        /// <summary>
        /// 转化成 java list,C#不能调用.
        /// </summary>
        /// <returns>List</returns>
        public System.Collections.Generic.IList<WorkSetting> ToJavaList()
        {
            return (System.Collections.Generic.IList<WorkSetting>)this;
        }
        /// <summary>
        /// 转化成list
        /// </summary>
        /// <returns>List</returns>
        public System.Collections.Generic.List<WorkSetting> Tolist()
        {
            System.Collections.Generic.List<WorkSetting> list = new System.Collections.Generic.List<WorkSetting>();
            for (int i = 0; i < this.Count; i++)
            {
                list.Add((WorkSetting)this[i]);
            }
            return list;
        }
        #endregion 为了适应自动翻译成java的需要,把实体转换成List.
    }
}
